cmake_minimum_required(VERSION 3.8)
project(behavior_controller)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cpp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overflow")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-parentheses")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(gazebo_msgs REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(nav2_msgs REQUIRED)
find_package(nav2_util REQUIRED)
find_package(nav2_costmap_2d REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(ipa_building_msgs REQUIRED)
find_package(sweeping_robot_msg REQUIRED)
find_package(pcl_conversions REQUIRED)
find_package(laser_geometry REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(OpenCV REQUIRED)
find_package(yaml_cpp_vendor REQUIRED)
find_package(PCL REQUIRED)
set(PCL_INCLUDE_DIRS /usr/include/pcl-1.12)  # 指定pcl路径
add_definitions(${PCL_DEFINITIONS})
find_package(Boost REQUIRED COMPONENTS
        system
        filesystem
        log
        log_setup
        thread
        date_time
        chrono
        iostreams
        serialization
        timer
        REQUIRED
        )

set(dependencies
        rclcpp
        rclcpp_action
        tf2
        tf2_ros
        tf2_geometry_msgs
        std_msgs
        gazebo_msgs
        sensor_msgs
        geometry_msgs
        pcl_conversions
        sweeping_robot_msg
        nav_msgs
        nav2_msgs
        nav2_util
        nav2_costmap_2d
        visualization_msgs
        ipa_building_msgs
        cv_bridge
        )

include_directories(
        include
        ${OpenCV_INCLUDE_DIRS}
        ${EIGEN3_INCLUDE_DIR}
        ${PCL_INCLUDE_DIRS}
        ${YAML_INCLUDEDIR}
)

file(GLOB_RECURSE ALL_LIBRARY_SRCS
    "${PROJECT_SOURCE_DIR}/src/data_struct/base/*.cpp"
    "${PROJECT_SOURCE_DIR}/src/lib/*.cpp"
    "${PROJECT_SOURCE_DIR}/src/apps/*.cpp"
    "${PROJECT_SOURCE_DIR}/src/Communication/*.cpp"
    "${PROJECT_SOURCE_DIR}/src/data_struct/robot/*.cpp"
    "${PROJECT_SOURCE_DIR}/src/modules/AssistModule/*.cpp"
    "${PROJECT_SOURCE_DIR}/src/modules/MonitorModule/*.cpp"
    "${PROJECT_SOURCE_DIR}/src/modules/CtrlModule/*.cpp"
    "${PROJECT_SOURCE_DIR}/src/modules/CtrlModule/ActivePlanner/*.cpp"
    "${PROJECT_SOURCE_DIR}/src/modules/CtrlModule/PassivePlanner/*.cpp"
    )

add_executable(nav2_pub_pt src/nav2_pub_pt.cpp)
target_link_libraries(nav2_pub_pt ${Boost_LIBRARIES})
ament_target_dependencies(nav2_pub_pt ${dependencies})

add_executable(${PROJECT_NAME}_exe ${ALL_LIBRARY_SRCS})
target_link_libraries(${PROJECT_NAME}_exe
        ${Boost_LIBRARIES}
        ${OpenCV_LIBS}
        ${YAML_LIBRARY}
        ${PCL_LIBRARIES}
        )
ament_target_dependencies(${PROJECT_NAME}_exe
        yaml_cpp_vendor
        ${dependencies})

install(TARGETS ${PROJECT_NAME}_exe DESTINATION lib/${PROJECT_NAME})
install(DIRECTORY DESTINATION share/${PROJECT_NAME})

ament_package()
